package com.jmp.dto;

import cn.hutool.crypto.SecureUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

/**
 * @author cjr
 */
@Data
@Slf4j
public class LiveRequest {
    /**
     * 推流事件为1；断流事件为0；录制事件为100；截图事件为200
     */
    private int event_type;
    private int t;
    private String sign;

    public boolean check() {
        if (System.currentTimeMillis()/1000 > t) {
            log.warn("event({}) t({}) is timeout", event_type, t);
            return false;
        }

        String signCheck = SecureUtil.md5("r3434akdfjaqeurihgskdq323" + t);
        if (!signCheck.equals(sign)) {
            log.warn("event({}) t({}) sign({}) not equals ({})", event_type, t, sign, signCheck);
            return false;
        }

        return true;
    }
}
